          # hull_points = []
        # for i in points:
        #     hull_points.append((i.x,i.y))

        # concave = hull.concave(hull_points, 0)
        # print(concave)


        # def get_origin_point(x,y):
        #     for p in points:
        #         if p.x == x and p.y == y:
        #             return p

        # polygon = Polygon('wall_group')
        # nxt = concave.pop(0)
        # while concave:
        #     p1 = nxt
        #     p2 = concave.pop(0)
        #     point1 = Point(get_origin_point(p1[0],p1[1]).origin)
        #     point2 = Point(get_origin_point(p2[0],p2[1]).origin)
        #     seg = Segment(None,"wall_group_segment",point1,point2)
        #     polygon.add_segment(seg)
        #     nxt = p2
        # print(polygon)
        # return polygon

        # polygon = Polygon('wall_group')
        # for p in points:
        #     for seg in p.segments:
        #         polygon.add_segment(seg)
        # return polygon
  
  
  
  # def get_origin_point(x,y):
        #     for p in points:
        #         if p.x == x and p.y == y:
        #             return p
        # shapely_polygon = geometry.Polygon([[p.x, p.y] for p in points])
        # shapely_points = list(zip(*shapely_polygon.exterior.coords.xy))
        # polygon = Polygon('wall_group')
        # nxt = shapely_points.pop(0)
        # while shapely_points:
        #     p1 = nxt
        #     p2 = shapely_points.pop(0)
        #     point1 = Point(get_origin_point(p1[0],p1[1]).origin)
        #     point2 = Point(get_origin_point(p2[0],p2[1]).origin)
        #     seg = Segment(None,"wall_group_segment",point1,point2)
        #     polygon.add_segment(seg)
        #     nxt = p2

        # return polygon

        # polygon = Polygon('wall_group')
        # first = nxt = list(points)[0]
        # input_points_count = len(list(points))
        # visted_points_count = 0
        # while nxt:
        #     this = nxt
        #     nxt = [p for p in this.links if not p.equals(this)][0]
        #     seg =  [seg for seg in this.segments if (seg.start == this and seg.end == nxt)][0]
        #     polygon.add_segment(seg)
        #     print('seg.start: ',seg.start)
        #     print('seg.end: ',seg.end)
        #     print('first: ',first)
        #     print('nxt: ',nxt)
        #     visted_points_count += 1
        #     print('visted_points_count: ',visted_points_count)

            
        #     if nxt.equals(first):
        #         break
        #     if visted_points_count > input_points_count:
        #         break
        # print('polygon segemnts len: ', len(polygon.segments))
        # return polygon



    # def buildPolygons(self, polygons, segments , output, step):
    #     global compute_step
    #     global max_compute_step
    #     compute_step += 1
    #     print('step: ', step)
    #     print('compute_step: ', compute_step)
    #     for polygon in polygons:
    #         if len(polygon.segments) > 10:
    #             pass
    #         elif polygon.is_closed_polygon():
    #             output.append(polygon)
    #         else:
    #             last_polygon_segment = polygon.get_last_segment()
    #             next_segments = self.find_next_segments(last_polygon_segment,segments)
    #             new_polygons = polygon.branch(next_segments)
    #             if step < 10 and compute_step < max_compute_step:
    #                 self.buildPolygons(new_polygons,segments,output, step + 1)
        
    # def combineSegments2Polygons(self, segments):
    #     polygons = []
    #     output = []
    #     for seg in segments:
    #         polygon = Polygon('computing')
    #         polygon.add_segment(seg)
    #         polygons.append(polygon)
    #     self.buildPolygons(polygons,segments,output,1)
    #     return output

    # def reducePolygons(self, polygons):
    #     return polygons



    # def find_next_segments(self, segment, segments):
    #     next_segments = []
    #     for seg in segments:
    #         if segment.end.equal(seg.start.co) and (not segment.equals(seg)):
    #             next_segments.append(seg)
    #     return next_segments



            
        # p = polygons[76]
        # self.bpy.p = p
        # print(p)
        # p.draw(self.bpy,-57600,0,0)

        #polygons = combineSegments2Polygons(segments)

        # print(len(polygons))
        # finalPolygons = reducePolygons(polygons)

        # draw(finalPolygons)

        #exec(open('find_rooms.py',encoding='UTF-8').read())



        #         print('start compute')
        # G = nx.Graph()
        # for pp in combinations(points,2):
        #     G.add_edge(pp[0],pp[1])

        # cover_edges = nx.min_edge_cover(G)
        # polygon = Polygon('wall_group')
        # while cover_edges:
        #     edge = cover_edges.pop()
        #     p1 = edge[0]
        #     p2 = edge[1]
        #     point1 = Point(p1.origin)
        #     point2 = Point(p2.origin)
        #     seg = Segment(None,"wall_group_segment",point1,point2)
        #     polygon.add_segment(seg)



         #把墙作为节点，门窗作为边构建一个图

        # G = nx.DiGraph()

        # def find_connected_opening(wall1,wall2):
        #     for opening in opening_polygons:
        #         if wall1.connected(opening) and wall2.connected(opening):
        #             return opening

        # for ww in permutations(wall_polygons):
        #     wall1 = ww[0]
        #     wall2 = ww[1]
        #     if find_connected_opening(wall1,wall2):
        #         G.add_edge(wall1,wall2)

        # ret = list(nx.simple_cycles(G))
        # print('find ' + str(len(ret)) + 'room')
        # print('build room polygons')

        # def build_room_polygon(walls):
        #     polygon = Polygon('room_polygon')
        #     frist = nxt = walls.pop(0)
        #     while walls:
        #         wall1 = nxt
        #         wall2 = walls.pop(0)

        #         connect_opening = find_connected_opening(wall1,wall2)
         
        #         seg = Segment(None,"room_segment",point1,point2)
        #         polygon.add_segment(seg)
        #         nxt = p2
        #     point1 = get_new_point(nxt)
        #     point2 = get_new_point(frist)
        #     seg = Segment(None,"convex_segment",point1,point2)
        #     polygon.add_segment(seg)
            
        
        # room_polygons = [build_room_polygon(c) for c in sorted(ret, key=len, reverse=True)]
        # self.drawElements(room_polygons)



        def find_connected_opening(wall1,wall2):
            for opening in opening_polygons:
                if wall1.connected(opening) and wall2.connected(opening):
                    return opening
        def find_connected_wall(opening1,opening2):
            for wall in wall_polygons:
                if opening1.connected(wall) and opening2.connected(wall):
                    return wall